package com.caijin.common.core.domain.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;

import com.caijin.common.core.domain.BaseEntity;
import com.caijin.common.core.domain.vo.CommentVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 评论表
 * </p>
 *
 * @author Peas
 * @since 2021-06-05
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("tb_comment")
@ApiModel(value = "Comment对象", description = "评论表")
public class Comment extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "评论id，主键，唯一标识，自增")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "父评论id")
    private Long parentId;

    @ApiModelProperty(value = "用户id")
    private Long userId;

    @ApiModelProperty(value = "头像")
    private String avatar;

    @ApiModelProperty(value = "昵称，最多8个字符")
    private String nickname;

    @ApiModelProperty(value = "所属文章id")
    private Long catalogueId;

    @ApiModelProperty(value = "点赞数")
    private Integer likeNum;

    @ApiModelProperty(value = "评论内容")
    private String content;

    @ApiModelProperty(value = "是否点赞")
    private String isLike;

    public CommentVO toVO(){
        CommentVO commentVO = new CommentVO();
        commentVO.setId(this.id);
        commentVO.setLikeNum(this.likeNum);
        commentVO.setNickname(this.nickname);
        commentVO.setAvatar(this.avatar);
        commentVO.setContent(this.content);
        commentVO.setParentId(this.parentId);
        commentVO.setCreateTime(this.getCreateTime());
        commentVO.setModifiedTime(this.getModifiedTime());
        commentVO.setIsLike(this.isLike);
        return commentVO;
    }

}
